package org.dinner.order.dao.impl;

import java.util.List;

import org.dinner.order.dao.UserDAO;
import org.dinner.order.model.User;
import org.springframework.stereotype.Repository;

@Repository
public class UserDAOImpl extends BaseDAOImpl<User> implements UserDAO {
	private static final String ENTITY_NAME = "User";
	
	@Override
	protected String getQueryPrefix() {
		return ENTITY_NAME;
	}
	
	public User getByLogin(String login) {
		List list = sessionFactory.getCurrentSession().getNamedQuery(ENTITY_NAME + ".getByLogin")
				.setParameter("login", login).list();
		if (list != null && list.size() > 0) {
			return (User) list.get(0);
		} else {
			return null;
		}
	}
}
